/*     */ package com.controller.front;
/*     */ 
/*     */ import base.dao.BaseExample;
/*     */ import base.dao.BaseExample.Criteria;
/*     */ import base.utils.ResultUtil;
/*     */ import base.utils.StringUtil;
/*     */ import base.utils.UploadFile;
/*     */ import com.model.Abstract;
/*     */ import com.model.Accessory;
/*     */ import com.service.AbstractService;
/*     */ import com.service.AccessoryService;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.ServletContext;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpSession;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ import org.springframework.web.multipart.MultipartFile;
/*     */ import org.springframework.web.multipart.MultipartHttpServletRequest;
/*     */ import org.springframework.web.servlet.ModelAndView;
/*     */ import org.springframework.web.servlet.view.json.MappingJacksonJsonView;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"abstract"})
/*     */ public class AbstractController
/*     */ {
/*     */   @Autowired
/*     */   private AbstractService abstractService;
/*     */   @Autowired
/*     */   private AccessoryService accessoryService;
/*     */   
/*     */   @RequestMapping({"uploadAbstract"})
/*     */   public ModelAndView uploadAbstract(HttpServletRequest request)
/*     */   {
/*  47 */     Map<String, Object> attributes = new HashMap();
/*  48 */     MappingJacksonJsonView view = new MappingJacksonJsonView();
/*  49 */     ModelAndView mv = new ModelAndView();
/*     */     try
/*     */     {
/*  52 */       String user_id = request.getParameter("user_id");
/*  53 */       BaseExample be = new BaseExample();
/*  54 */       be.or().andEqualTo("abstract_user", user_id);
/*  55 */       List<Map<?, ?>> resList = this.abstractService.selectByExample(be);
/*  56 */       Abstract a = null;
/*  57 */       if (resList.size() == 0) {
/*  58 */         a = new Abstract();
/*     */       } else {
/*  60 */         String abstract_id = ((Map)resList.get(0)).get("abstract_id").toString();
/*  61 */         a = (Abstract)this.abstractService.selectByPrimaryKey(abstract_id);
/*     */       }
/*     */       
/*  64 */       String accid = "";
/*  65 */       if ((a.getAbstract_accid() == null) || ("".equals(a.getAbstract_accid()))) {
/*  66 */         accid = StringUtil.createUUID();
/*     */       } else {
/*  68 */         accid = a.getAbstract_accid();
/*     */       }
/*     */       
/*  71 */       ServletContext context = request.getSession().getServletContext();
/*  72 */       String filepath = context.getRealPath("/") + "../accessory/";
/*     */       
/*  74 */       MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest)request;
/*  75 */       int size = multipartRequest.getFiles("upload1").size();
/*  76 */       for (int i = 0; i < size; i++) {
/*  77 */         MultipartFile file = (MultipartFile)multipartRequest.getFiles("upload1").get(i);
/*  78 */         if ((file != null) || (file.getSize() > 0L)) {
/*  79 */           String uploadFileName = UploadFile.uploadFile2(file, filepath);
/*  80 */           if (!"".equals(uploadFileName)) {
/*  81 */             Accessory acc = new Accessory();
/*  82 */             acc.setAccessory_id(accid);
/*  83 */             acc.setAccessory_name(file.getOriginalFilename());
/*  84 */             acc.setAccessory_url(uploadFileName);
/*  85 */             acc.setDeleteFlag(0);
/*  86 */             acc.setAddTime(new Date());
/*  87 */             this.accessoryService.insertByEntity(acc);
/*     */           }
/*     */         }
/*     */       }
/*  91 */       a.setAbstract_accid(accid);
/*  92 */       a.setDeleteFlag(0);
/*  93 */       a.setAbstract_user(Integer.parseInt(user_id));
/*     */       
/*  95 */       if (resList.size() == 0) {
/*  96 */         this.abstractService.insertByEntity(a);
/*     */       } else {
/*  98 */         this.abstractService.updateByEntity(a);
/*     */       }
/*     */       
/* 101 */       Map<String, Object> map = new HashMap();
/* 102 */       return ResultUtil.returnJsonStr("0", "ok", attributes, map, view, mv);
/*     */     }
/*     */     catch (Exception e) {
/* 105 */       e.printStackTrace();
/* 106 */       Map<String, Object> map = new HashMap();
/* 107 */       return ResultUtil.returnJsonStr("1", "系统错误", attributes, map, view, mv);
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   @RequestMapping({"refuse"})
/*     */   public ModelAndView refuse(HttpServletRequest request)
/*     */   {
/* 119 */     ModelAndView mv = new ModelAndView();
/* 120 */     Map<String, Object> attributes = new HashMap();
/* 121 */     MappingJacksonJsonView view = new MappingJacksonJsonView();
/*     */     try
/*     */     {
/* 124 */       String message = new String(request.getParameter("message").getBytes("ISO-8859-1"), "utf-8");
/* 125 */       String acc_id = request.getParameter("acc_id");
/* 126 */       if (("".equals(acc_id)) || (acc_id == null)) {
/* 127 */         Map<String, Object> map = new HashMap();
/* 128 */         return ResultUtil.returnJsonStr("1", "acc_id参数为空", attributes, map, view, mv);
/*     */       }
/* 130 */       if (("".equals(message)) || (message == null)) {
/* 131 */         Map<String, Object> map = new HashMap();
/* 132 */         return ResultUtil.returnJsonStr("1", "message参数为空", attributes, map, view, mv);
/*     */       }
/*     */       
/* 135 */       Accessory acc = (Accessory)this.accessoryService.selectByPrimaryKey(acc_id);
/* 136 */       acc.setAccessory_zt("2");
/* 137 */       acc.setAccessory_con(message);
/* 138 */       this.accessoryService.updateByEntity(acc);
/* 139 */       Map<String, Object> map = new HashMap();
/* 140 */       return ResultUtil.returnJsonStr("0", "ok", attributes, map, view, mv);
/*     */     }
/*     */     catch (Exception e) {
/* 143 */       e.printStackTrace();
/* 144 */       Map<String, Object> map = new HashMap();
/* 145 */       return ResultUtil.returnJsonStr("1", "系统错误", attributes, map, view, mv);
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   @RequestMapping({"pass"})
/*     */   public ModelAndView pass(HttpServletRequest request)
/*     */   {
/* 156 */     ModelAndView mv = new ModelAndView();
/* 157 */     Map<String, Object> attributes = new HashMap();
/* 158 */     MappingJacksonJsonView view = new MappingJacksonJsonView();
/*     */     try {
/* 160 */       String acc_id = request.getParameter("acc_id");
/* 161 */       if (("".equals(acc_id)) || (acc_id == null)) {
/* 162 */         Map<String, Object> map = new HashMap();
/* 163 */         return ResultUtil.returnJsonStr("1", "acc_id参数为空", attributes, map, view, mv);
/*     */       }
/*     */       
/* 166 */       Accessory acc = (Accessory)this.accessoryService.selectByPrimaryKey(acc_id);
/* 167 */       acc.setAccessory_zt("3");
/* 168 */       this.accessoryService.updateByEntity(acc);
/* 169 */       Map<String, Object> map = new HashMap();
/* 170 */       return ResultUtil.returnJsonStr("0", "ok", attributes, map, view, mv);
/*     */     }
/*     */     catch (Exception e) {
/* 173 */       e.printStackTrace();
/* 174 */       Map<String, Object> map = new HashMap();
/* 175 */       return ResultUtil.returnJsonStr("1", "系统错误", attributes, map, view, mv);
/*     */     }
/*     */   }
/*     */   
/*     */   @RequestMapping({"abstractDel"})
/*     */   public ModelAndView abstractDel(HttpServletRequest request) {
/* 181 */     ModelAndView mv = new ModelAndView();
/* 182 */     Map<String, Object> attributes = new HashMap();
/* 183 */     MappingJacksonJsonView view = new MappingJacksonJsonView();
/*     */     try {
/* 185 */       String id = request.getParameter("acc_id");
/* 186 */       Accessory accessory = (Accessory)this.accessoryService.selectByPrimaryKey(id);
/* 187 */       accessory.setDeleteFlag(1);
/* 188 */       this.accessoryService.updateByEntity(accessory);
/* 189 */       Map<String, Object> map = new HashMap();
/* 190 */       return ResultUtil.returnJsonStr("0", "ok", attributes, map, view, mv);
/*     */     }
/*     */     catch (Exception e) {
/* 193 */       e.printStackTrace();
/* 194 */       Map<String, Object> map = new HashMap();
/* 195 */       return ResultUtil.returnJsonStr("1", "系统错误", attributes, map, view, mv);
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   @RequestMapping({"getabstractList"})
/*     */   public ModelAndView getposterList(HttpServletRequest request)
/*     */   {
/* 206 */     ModelAndView mv = new ModelAndView();
/* 207 */     Map<String, Object> attributes = new HashMap();
/* 208 */     MappingJacksonJsonView view = new MappingJacksonJsonView();
/*     */     try
/*     */     {
/* 211 */       String user_id = request.getParameter("user_id");
/*     */       
/* 213 */       BaseExample ba = new BaseExample();
/* 214 */       ba.or().andEqualTo("abstract_user", user_id);
/* 215 */       ba.leftJoinOn("Accessory", "Accessory_id", "abstract_accid");
/* 216 */       ba.or(0).andEqualTo("Accessory", "DeleteFlag", "0");
/* 217 */       ba.or(0).andEqualTo("deleteFlag", "0");
/* 218 */       ba.setOrderByClause("addTime");
/* 219 */       List<Map<?, ?>> l1 = this.abstractService.selectByExample(ba);
/*     */       
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 225 */       attributes.put("code", "0");
/* 226 */       attributes.put("msg", "ok");
/* 227 */       attributes.put("date", l1);
/* 228 */       view.setAttributesMap(attributes);
/* 229 */       mv.setView(view);
/* 230 */       return mv;
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 234 */       e.printStackTrace();
/*     */       
/*     */ 
/* 237 */       attributes.put("code", "1");
/* 238 */       attributes.put("msg", "系统错误");
/* 239 */       view.setAttributesMap(attributes);
/* 240 */       mv.setView(view); }
/* 241 */     return mv;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   @RequestMapping({"getabstractNewList"})
/*     */   public ModelAndView getabstractNewList(HttpServletRequest request)
/*     */   {
/* 252 */     ModelAndView mv = new ModelAndView();
/* 253 */     Map<String, Object> attributes = new HashMap();
/* 254 */     MappingJacksonJsonView view = new MappingJacksonJsonView();
/*     */     try
/*     */     {
/* 257 */       String user_id = request.getParameter("user_id");
/*     */       
/* 259 */       BaseExample ba = new BaseExample();
/* 260 */       ba.or().andEqualTo("abstract_user", user_id);
/* 261 */       ba.leftJoinOn("Accessory", "Accessory_id", "abstract_accid").or(0).andEqualTo("Accessory", "DeleteFlag", Integer.valueOf(0));
/* 262 */       ba.or(0).andEqualTo("deleteFlag", "0");
/* 263 */       ba.setOrderByClause("Accessory.addTime desc");
/* 264 */       List<Map<?, ?>> l = this.abstractService.selectByExample(ba);
/* 265 */       if (l.size() == 0) {
/* 266 */         List<Map<?, ?>> m = new ArrayList();
/* 267 */         Object o = null;
/* 268 */         attributes.put("code", "0");
/* 269 */         attributes.put("msg", "ok");
/* 270 */         attributes.put("date", o);
/* 271 */         view.setAttributesMap(attributes);
/* 272 */         mv.setView(view);
/* 273 */         return mv;
/*     */       }
/* 275 */       Map<?, ?> m = (Map)l.get(0);
/*     */       
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 281 */       attributes.put("code", "0");
/* 282 */       attributes.put("msg", "ok");
/* 283 */       attributes.put("date", m);
/* 284 */       view.setAttributesMap(attributes);
/* 285 */       mv.setView(view);
/* 286 */       return mv;
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 290 */       e.printStackTrace();
/*     */       
/*     */ 
/* 293 */       attributes.put("code", "1");
/* 294 */       attributes.put("msg", "系统错误");
/* 295 */       view.setAttributesMap(attributes);
/* 296 */       mv.setView(view); }
/* 297 */     return mv;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   @RequestMapping({"jump"})
/*     */   public ModelAndView jump(HttpServletRequest request)
/*     */   {
/* 307 */     ModelAndView mv = new ModelAndView();
/* 308 */     mv.setViewName("/uploadp.jsp");
/* 309 */     return mv;
/*     */   }
/*     */ }


/* Location:              C:\Users\chengkp\Desktop\interwar\WEB-INF\classes\!\com\controller\front\AbstractController.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */